#!/bin/bash
#========================================================================
# Author: YSLin
# Email: 
# File Name: dirChk_Crt.sh
# Description: 
#   
# Edit History: 
#   2010-12-17    File created.
#========================================================================
#${#array[@]} 代表所有array總數
#${array[0]} 是array的第一個變數值, 也就是從0開始, 最大值-1也就是最後一個值
apk_type_dir=(
APPLICATIONS  
GAMES
)
#檢查apk下載目的資料夾是否建立
APPLICATIONS_apk_dir=(
COMICS  
COMMUNICATION  
DEMO  
ENTERTAINMENT  
FINANCE  
HEALTH  
LIBRARIES  
LIFESTYLE  
MULTIMEDIA  
NEWS  
PRODUCTIVITY  
REFERENCE  
SHOPPING  
SOCIAL  
SPORTS  
THEMES  
TOOLS  
TRAVEL                                                                                                                                                                                       
)
GAMES_apk_dir=(
"Arcade & Action"                                                                                                                                                                            
"Brain & Puzzle"
"Cards & Casino"
Casual
)
for ((i=0; i<${#APPLICATIONS_apk_dir[@]}; i++)); do    #請注意 ((   )) 雙層括號
	if ! [ -e ${apk_type_dir[0]} ] ; then
		echo "creating ${apk_type_dir[0]}"
		mkdir ${apk_type_dir[0]}
	fi
	if ! [ -e ${apk_type_dir[0]}/${APPLICATIONS_apk_dir[$i]} ] ; then
		echo "creating ${apk_type_dir[0]}/${APPLICATIONS_apk_dir[$i]}"
		mkdir ${apk_type_dir[0]}/${APPLICATIONS_apk_dir[$i]} 
	fi
done

for ((i=0; i<${#GAMES_apk_dir[@]}; i++)); do    #請注意 ((   )) 雙層括號
    echo  
	if ! [ -e ${apk_type_dir[1]} ] ; then
		echo "creating ${apk_type_dir[1]}"
		mkdir ${apk_type_dir[1]}
	fi
	if ! [ -e ${apk_type_dir[1]}/"${GAMES_apk_dir[$i]}" ] ; then
		echo "creating ${apk_type_dir[1]}/""${GAMES_apk_dir[$i]}"
		mkdir ${apk_type_dir[1]}/"${GAMES_apk_dir[$i]}"
	fi
done

